import Vue from 'vue'
import Vuex from 'vuex'
import createPersistedState from 'vuex-persistedstate'
Vue.use(Vuex)

export default new Vuex.Store({
  plugins: [
    createPersistedState({
      key: 'COKEN',
      reducer({ coken, outlogin, historles }) {
        return { coken, outlogin, historles }
      }
    })
  ],

  state: {
    coken: {},
    outlogin: [],
    historles: []
  },
  getters: {
    isgetshow(state) {
      //   if(state.coken.coken){
      //     return true
      //   }else{
      //     return false
      //   }
      return !!state.coken
    }
  },
  mutations: {
    SET_TOKEN(state, val) {
      state.coken = val
    },
    OUTLOGIN(state, val) {
      console.log(val)
      state.outlogin = val
    },
    SET_HISTORLES(state, historles) {
      state.historles = historles
    }
  },
  actions: {},
  modules: {}
})
